package com.api.demo.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

/**
 * 〈Rest接口〉
 *
 * @author Administrator
 * @create 2021/2/20
 * @since 1.0.0
 */
@Path("/workflow/v2")
public class TestActionApi {
    @GET
    @Path("/test")
    @Produces(MediaType.TEXT_PLAIN)
    public String test(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        JSONObject object = new JSONObject();
        object.put("test", "test");
        Logger logger = LoggerFactory.getLogger("debug");
        // 支持占位符输出, 不定参数
        logger.debug("debug级别消息: {}, {}", object, "参数2");
        logger.info("info级别消息!");
        logger.error("error级别消息!");
        return JSON.toJSONString(object);
    }
}